package com.lianniu.mgr.projectMgr.projectInfo.service.impl;

import java.util.List;

import com.lianniu.mgr.base.BaseResult;
import com.lianniu.mgr.projectMgr.projectInfo.dao.IProjectProcessMapperDao;
import com.lianniu.mgr.projectMgr.projectInfo.model.ProjectProcessVo;
import com.lianniu.mgr.projectMgr.projectInfo.service.IProjectProcessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class ProjectProcessServiceImpl implements IProjectProcessService {

	@Autowired
	IProjectProcessMapperDao projectProcessMapperDao;
  
  	/**
	 * @Description:根据项目id获取项目进度的列表信息
	 * @param projectId 项目id
	 * @return BaseResult(List<ProjectVo>) 查询记录列表

	 * @Date:2016年4月13日下午8:36:19
	 * @Version 1.0.0
	 */
	@Override
	public BaseResult getProjectProcessesByProjectId(String projectId) {
	    return BaseResult.success(projectProcessMapperDao.getProjectProcessesByProjectId(projectId));
	}
  
	/**
	 * @Description:批量添加项目进度记录
	 * @param list 项目信息列表
	 * @return BaseResult

	 * @Date:2016年4月13日下午8:36:19
	 * @Version 1.0.0
	 */
	@Override
	@Transactional
	public BaseResult addProjectProcesses(List<ProjectProcessVo> list) {
		/*
		BaseResult baseResult;
	    if (StringUtil.isEmpty(process.getProjectId())) {
	      baseResult = BaseResult.fail(ErrorCode.ParaCheckErrorRetCode, ErrorCode.ParaCheckErrorRetInfo);
	      return baseResult;
	    }
	    */
		ProjectProcessVo projectProcessVo = list.get(0);
		projectProcessMapperDao.delProjectProcessesByProjectId(projectProcessVo.getProjectId());
	    return BaseResult.success(projectProcessMapperDao.addProjectProcesses(list));
	}
  
	/**
	 * @Description:根据项目id列表批量删除项目进度记录
	 * @param ids 项目id列表
	 * @return BaseResult

	 * @Date:2016年4月13日下午8:36:19
	 * @Version 1.0.0
	 */
	@Override
	public BaseResult delProjectProcessesByProjectIds(List<String> ids) {
		return BaseResult.success(projectProcessMapperDao.delProjectProcessesByProjectIds(ids));
	}
  
}
